
<!-- 增加页面开始 -->
[#macro tenantuserroleAddView]
    <div  class="model-form">
        <el-page-header @back="goBack" content="增加角色">
        </el-page-header>
        <div class="model-content">
            <el-form ref="ruleForm" :rules="rules" :model="form" label-width="160px" >
                <el-row :gutter="10">
                        <el-col :span="12">
                            <el-form-item label="角色名" size="mini" prop="name">
                                    <el-input v-model="form.name" name="name">
                                    </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="角色别名" size="mini" prop="alias">
                                    <el-input v-model="form.alias" name="alias">
                                    </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="排序号" size="mini" prop="sortNum">
                                <el-input-number v-model="form.sortNum" name="sortNum" type="textarea" :min="0" :max="100"></el-input-number>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="角色描述" size="mini" prop="description">
                                    <el-input v-model="form.description" name="description" type="textarea"></el-input>
                            </el-form-item>
                        </el-col>
                </el-row>
                <el-row style="text-align: right;">
                    <el-button @click="goBack">取消</el-button>
                    <el-button type="primary" @click="add">确定</el-button>
                </el-row>
            </el-form>
        </div>
    </div>
[/#macro]

[#macro tenantuserroleAddConfig]
<script type="text/x-template" id="my-tenantuserrole-add">
	[@tenantuserroleAddView /]
</script>
<script type="text/javascript">
		//添加组件开始
		var tenantuserroleAddConfig = {};
		tenantuserroleAddConfig.template = "#my-tenantuserrole-add";
		tenantuserroleAddConfig.methods = config.basicMethod();
		tenantuserroleAddConfig.data = function () {
			return {
				form: {
					name: '',
					alias: '',
					sortNum: '',
					description: ''				},
				rules: {
                        name: [
							{ required: true, message: '请输入角色名', trigger: 'blur' }
						],
				}
			}
		};
		tenantuserroleAddConfig.mounted = function () {
		}
		tenantuserroleAddConfig.computed = {};


		tenantuserroleAddConfig.methods.add = function () {
			var self = this;
			this.$refs["ruleForm"].validate(function(valid){
				if (valid) {
					self.addData();
				} else {
					console.log('error submit!!');
					return false;
				}
			});
		}

		tenantuserroleAddConfig.methods.addData = function () {
			var self = this, data = this.form;
			if (this.deforeAddData) {
				this.deforeAddData();
			}
			this.postData("${siteurl}tenantRest/tenantuserrole/create.htm", data, function (res) {
				if (res.code == 0) {
					self.$message({
						message: '添加数据成功',
						type: 'success'
					});
					self.$router.go(-1);
				} else {
					self.$message.error(res.msg);
				}
			});
		}
		var  tenantuserroleAddView = Vue.component('add-view', tenantuserroleAddConfig);


</script>
[/#macro]

<!-- 增加页面结束 -->